// pages/home/home.js

const app = getApp();

//初始化数据库
const db = wx.cloud.database()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    //用户对象
    userInfo: {},
    //登陆状态
    logged: false,
    //是否获取到缓存信息
    takeSession: false,
    //请求返回数据
    requestResult: ''
  },
  clickHeader:function(){
    //点击登陆按钮提示
    wx.showModal({
      title: '提示',
      content: '登陆后可完整使用，您可暂不登陆',
      success: function (res) {
        if (res.confirm) {
          wx.navigateTo({
            url: '../login/login',
          })
        }else{
        }
      }
    })
    
  },
  //返回本页后刷新页面 并重新注入用户信息
  onShow: function () {
    this.setData({
      userInfo: app.globalData.userInfo
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //读取全局变量用户相关信息
    this.setData({
      userInfo: app.globalData.userInfo
    })
    //自适应页面组件长宽
    var viewWidth = wx.getSystemInfoSync().windowWidth
    var viewHeight = wx.getSystemInfoSync().windowHeight
    var contentItemWidth = (viewWidth - 60) / 2
    var contentItemHeight = contentItemWidth
    var contentY = (viewHeight - 200 - (contentItemHeight * 2) - 20) / 2
    var contentWidth = contentItemWidth * 2 + 20
    var contentItemImgWidth = contentItemWidth / 2.5
    var contentItemImgHeight = contentItemImgWidth
    this.setData({
      contentY: contentY,
      contentWidth: contentWidth,
      contentItemWidth: contentItemWidth,
      contentItemHeight: contentItemHeight,
      contentItemImgWidth: contentItemImgWidth,
      contentItemImgHeight: contentItemImgHeight,
    })

  
  },
  //跳转单词学习页面
  clickXueXi: function () {
    wx.navigateTo({
      url: '../xuexi/index/index?title=单词学习',
    })
  },

  //错词
  clickCuoCi: function () {
    wx.navigateTo({
      url: '/pages/cuoci/index/index?title=学习记录和错词',
    })
  },

  //检索
  clickJuZi: function () {
    wx.navigateTo({
      url: '../jiansuo/jiansuo?title=检索',
    })
  },
  //自我检测
  clickDuiZhan:function() {
    wx.navigateTo({
      url: '../jiance/home/home?title=测验',
    })
  }


})